<template>
	<view class="cart-container">
		<view class="noCart" v-if="cartList<=0">
			<image src="/static/image/shoppingCar.png" mode="widthFix"></image>
			<text>购物车还是空的</text>
			<navigator url="/pages/index/index" open-type="switchTab">到小米商城逛逛</navigator>
		</view>
		<view class="haveCart" v-else>
			<block v-for="(item,index) in cartList" :key="index">
				<CartItem :title="item.title" :num="item.num" :price="item.price" :pic="item.pic" :chosen="item.chosen"></CartItem>
			</block>
		</view>
	</view>
</template>

<script>
	import {mapState} from 'vuex';
	import CartItem from '@/components/CartItem.vue'
	export default {
		components:{
			CartItem
		},
		data() {
			return {
				
			}
		},
		methods: {
		},
		computed:{
			...mapState(['cartList']),
		}
	}
	
</script>

<style lang="less" scoped>
.noCart{
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	width: 100%;
	height: 100%;
	image{
		margin-top: 70rpx;
		width: 30%;
	}
	text{
		margin-top: 50rpx;
		font-size: 30rpx;
	}
	navigator{
		display: flex;
		justify-content: center;
		align-items: center;
		margin-top: 50rpx;
		height: 100rpx;
		width: 60%;
		border-radius: 10rpx;
		background-color: #fb6600;
		color: #fff;
		
	}
}
.haveCart{
	display: flex;
}
</style>
